#coding:utf-8
def MaxMin_demo(LIST):
    Max_item = LIST[0]
    for item in LIST:
        if Max_item <= item:
            Max_item = item
        else:
            Min_item = item
    print Max_item
    print Min_item



aa= input('list:')
MaxMin_demo(aa)